<template>
  <!-- 
    判断一个对象是不是空对象
    Object.keys(obj).length == 0
   -->
  <div v-if="Object.keys(goods).length !== 0" class="base-info">
    <div class="info-title">{{ goods.title }}</div>
    <div class="info-price">
      <span class="n-price">{{ goods.newPrice }}</span>
      <span class="o-price">{{ goods.oldPrice }}</span>
      <span class="discount">{{ goods.discount }}</span>
    </div>

    <div class="info-other">
       <span>{{ goods.columns[0] }}</span>
       <span>{{ goods.columns[1] }}</span>
       <span>{{ goods.services[goods.services.length - 1].name }}</span>
    </div>

    <div class="info-service">
      <span class="info-service-item"
            v-for="index in goods.services.length - 1"
            :key="index">
        <img :src="goods.services[index - 1].icon" alt="">
        <span>{{goods.services[index - 1].name}}</span>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  name: "DetailBaseInfo",
  props: {
    goods: {
      type: Object,
      default() {
        return {};
      },
    },
  },
};
</script>

<style scoped>
.base-info {
  margin-top: 15px;
  padding: 0 8px;
  color: #999;
  border-bottom: 5px solid #f2f5f8;
}
.info-title{
  color: black;
  font-size: 18px;
  font-weight: 500;
}
.info-price{
  margin: 10px 0 10px 5px;
}
.n-price{
  color: #F86A99;
  font-size: 25px;
}
.o-price{
  text-decoration: line-through;
}
.discount{
  font-size: 15px;
  padding: 2px 5px;
  color: #fff;
  border-radius: 5px;
  background-color: var(--color-high-text);
  margin-left: 5px;
  /* 位置调整，上浮 */
  position: relative;
  top: -8px;
}
.info-other{
  margin-top: 15px;
  line-height: 30px;
  font-size: 15px;
  border-bottom: 1px solid rgba(100,100,100,.1);
  justify-content: space-between;
  display: flex;
}
.info-service {
  display: flex;
  justify-content: space-between;
  line-height: 60px;
}

.info-service-item img {
  width: 13px;
  height: 13px;
  margin-right: 3px;
  /* position: relative; */
  vertical-align: middle;
}

.info-service-item span {
  font-size: 15px;
  color: #333;
}
</style>
